package com.cyys.modules.core.utils.exportExcel;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.style.column.AbstractHeadColumnWidthStyleStrategy;

import java.util.List;
import java.util.Map;

public class DataColumnWidthStrategy extends AbstractHeadColumnWidthStyleStrategy {

    List<Map<String,String>> colList;

    public DataColumnWidthStrategy(List<Map<String,String>> colList) {
        this.colList = colList;
    }

    @Override
    protected Integer columnWidth(Head head, Integer columnIndex) {
        int width= colList.get(columnIndex).get("title").length()*4;
        if(width>255){
            width= 255;
        }
       return width;
    }
}